package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

var path  ="../access_log.202004182045"
func main()  {
	//path = "./access_log.202004181815"
	f,err:=os.Open(path)
	defer f.Close()
	if err!=nil{
		fmt.Println("err",err.Error())
	}
		buff := bufio.NewReader(f)
		for {
			data ,_,eof:=buff.ReadLine()
			if eof ==io.EOF{
				break
			}
			write(string(data))
			//fmt.Println(string(data))

		}
}
func write(data string){
	wpath := "./access.log"
	f,err:=os.OpenFile(wpath,os.O_RDWR|os.O_CREATE|os.O_APPEND,0644)
	if err!=nil{
		fmt.Println("err write file ",err.Error())
	}
	defer f.Close()
	_,err=f.WriteString(data+"\n")
	//fmt.Println("\t err",err.Error())
}